package cn.itcast.controller;

import cn.itcast.domain.company.Company;
import cn.itcast.service.company.CompanyService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CompanyController {

    @Reference
    private CompanyService companyService;


    @RequestMapping("/apply.do")
    @ResponseBody
    //返回一个普通字符串或者json数据都需要添加 @ResponseBody
    public String apply(Company company) {

        try {
            company.setState(0);

            companyService.save(company);
            return "1";  //代表成功
        } catch (Exception e) {
            e.printStackTrace();
            return "0";  //代表失败

        }


    }


}
